<template>
	<view class="main">
		<view class="content" v-if="is_server == 2">
			<image class="img" src="/static/img/enterpriseServer/server_state_process.png" mode="scaleToFill" />
			<view class="process">审核中…</view>
			<view class="dsc">您的申请已成功提交，会在1-3个工作日内 审核完毕，请留意！</view>

			<view class="footer">
				<view class="txt">有问题？</view>
				<view class="consult" @click="WXOpenCustomerServiceChat">咨询客服</view>
			</view>
		</view>

		<view class="content" v-if="is_server == 1">
			<image class="img" src="/static/img/enterpriseServer/server_state_success.png" mode="scaleToFill" />
			<view class="success">恭喜您，已成为服务商</view>
		</view>
	</view>
</template>

<script>
import homeApi from "@/static/js/enterpriseServer/index.js"
export default {
	data() {
		return {
			userInfo: {},
			is_server: '',
		};
	},
	onLoad(e) {
		this.getUserInfo();
	},
	methods: {
		//打开微信客服
		WXOpenCustomerServiceChat() {
			// #ifndef APP-PLUS
			uni.showToast({
				title: '请在app打开',
				icon: "none"
			});
			// #endif
			let wechat = null
			plus.share.getServices(res => {
				wechat = res.find(i => i.id === 'weixin')
				if (wechat) {
					wechat.openCustomerServiceChat({
						corpid: 'ww447880e03d7eba27', //企业ID
						url: 'https://work.weixin.qq.com/kfid/kfc8ba259d66968b838', //客服地址
					}, src => {
						console.log("success:", JSON.stringify(src))
					}, err => {
						console.log("error:", JSON.stringify(err))
					})
				} else {
					uni.showToast({
						title: '当前环境不支持微信操作',
						icon: "error"
					});
				}
			}, function () {
				uni.showToast({
					title: "获取服务失败，不支持该操作。" + JSON.stringify(e),
					icon: 'none'
				})
			});
		},

		getUserInfo() {
			homeApi.getUserInfo().then(res => {
				if (res.code === 1) {
					this.userInfo = res.data;
					this.is_server = res.data.is_server;
				}
			})
		},
	},
}
</script>

<style lang="scss" scoped>

.main {
	width: 100vw;
	min-height: 100vh;
	background: #fff;

	.content {
		width: 677rpx;
		position: absolute;
		top: 25%;
		left: 50%;
		transform: translate(-50%, -25%);
		display: flex;
		flex-direction: column;
		align-items: center;

		.img {
			width: 145rpx;
			height: 145rpx;
		}

		.process {
			margin-top: 26rpx;
			font-size: 32rpx;
			color: #333333;
			line-height: 44rpx;
		}

		.success {
			font-size: 32rpx;
			color: #333333;
			line-height: 44rpx;
		}

		.dsc {
			margin-top: 26rpx;
			font-size: 24rpx;
			color: #9E9E9E;
			line-height: 36rpx;
		}

		.footer {
			display: flex;
			align-items: center;
			font-size: 24rpx;
			margin-top: 26rpx;

			.txt {
				color: #666666;
			}

			.consult {
				color: #1C87F3;
			}
		}
	}
}
</style>
